package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.BatchStation;
import com.indusfo.spc.service.BatchStationService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Author liub
 * @Date 2019/12/5 10:44
 * @Version 1.0
 */

@Controller
@RequestMapping(value = "/service/batchStation")
public class BatchStationController {


    @Autowired
    private BatchStationService batchStationService;

    /**
     * 查询
     */
    @RequestMapping(value = "/queryBatchStation")
    @ResponseBody
    public JSONObject queryBatchStation(BatchStation batchStation) {
        JSONObject json = batchStationService.queryBatchStation(batchStation);
        return json;
    }

    /**
     * 新增
     */
    @RequestMapping(value = "/insertBatchStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertBatchStation(BatchStation batchStation) {
        JSONObject json = batchStationService.insertBatchStation(batchStation);
        return json;
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/updateBatchStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject updateBatchStation(BatchStation batchStation) {
        JSONObject json = batchStationService.updateBatchStation(batchStation);
        return json;
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/deleteBatchStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject deleteBatchStation(@RequestParam("batchStationIds") List<Integer> batchStationIds, Integer dataState) {
        dataState = 2;
        JSONObject json = batchStationService.deleteBatchStation(batchStationIds, dataState);
        return json;
    }

    /**
     * 启停
     */
    @RequestMapping(value = "/definedBatchStation", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject definedBatchStation(@RequestParam("batchStationIds") List<Integer> batchStationIds, Integer dataState) {
        JSONObject json = batchStationService.deleteBatchStation(batchStationIds, dataState);
        return json;
    }

}
